home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacTech 1 to 12
/
MacTech-vol-1-12.toast
/
Tools
/
Alpha 6.51b13 ƒ
/
Tcl
/
UserCode
/
editLastFile.tcl
< prev
next >
Wrap
Text File
|
1996-08-15
|
2KB
|
97 lines
# FILE: editLastFile.tcl
#
# LAST UPDATE: 01/08/93 5:53:54 AM
#
# This file contains the following TCL procedure(s):
#
# closeHook -- renames original and adds support functionality
# editLastFile -- allows editing previous file closed (bound CMD-SHIFT-W)
# editRecentFile -- allows a list pick of recent files
# COPYRIGHT:
#
# Copyright © 1992,1993 by David C. Black All rights reserved.
# Portions copyright © 1990, 1991, 1992 Pete Keleher. All Rights Reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by David C. Black in conjunction with Pete Keleher.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
################################################################################
# AUTHOR
#
# David C. Black
# Internet: black@mpd.tandem.com (preferred)
# GEnie: D.C.Black
# USnail: 6217 John Chisum Lane, Austin, TX 78749
#
################################################################################
proc editLastFile {} {
global lastStack
set i [llength $lastStack]
if {!$i} {
beep
message "Nothing to open"
return
}
set lastFile [lindex $lastStack [incr i -1]]
set lastStack [lrange $lastStack 0 [incr i -1]]
if {[file readable $lastFile]} {
edit $lastFile
} else {
beep
alertnote "Missing $lastFile"
}
}
#endproc editLastFile
proc editRecentFile {} {
global lastStack
if {![llength $lastStack]} {
beep
alertnote "Nothing to open"
return
}
set lastFile [listpick [lsort $lastStack]]
if {[string length $lastFile]} {
set i [lsearch $lastStack $lastFile]
set lastStack [lreplace $lastStack $i $i]
if {[file readable $lastFile]} {
edit $lastFile
} else {
beep
alertnote "Missing $lastFile"
}
}
}
#endproc editRecentFile
if {[info procs original-closeHook] != "original-closeHook"} {
rename closeHook original-closeHook
set lastStack {}
proc closeHook {name} {
set result [eval original-closeHook {$name}]
global lastStack
lappend lastStack $name
return $result
}
#endproc closeHook
addMenuItem fileUtils editRecentFile…
bind 'w' <csz> editLastFile
}
#endif